package com.change.declare.declare.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.change.declare.declare.entity.OrderitemsEntity;
import com.change.declare.declare.service.OrderitemsService;
import com.change.common.utils.PageUtils;
import com.change.common.utils.R;



/**
 * 
 *
 * @author LK
 * @email hmscrdlk@gmail.com
 * @date 2020-07-11 23:05:53
 */
@RestController
@RequestMapping("declare/orderitems")
public class OrderitemsController {
    @Autowired
    private OrderitemsService orderitemsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("declare:orderitems:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderitemsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{orderitemid}")
    //@RequiresPermissions("declare:orderitems:info")
    public R info(@PathVariable("orderitemid") Long orderitemid){
		OrderitemsEntity orderitems = orderitemsService.getById(orderitemid);

        return R.ok().put("orderitems", orderitems);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("declare:orderitems:save")
    public R save(@RequestBody OrderitemsEntity orderitems){
		orderitemsService.save(orderitems);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("declare:orderitems:update")
    public R update(@RequestBody OrderitemsEntity orderitems){
		orderitemsService.updateById(orderitems);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("declare:orderitems:delete")
    public R delete(@RequestBody Long[] orderitemids){
		orderitemsService.removeByIds(Arrays.asList(orderitemids));

        return R.ok();
    }

}
